export const regObj = {
    REGEXP_COMMA: new RegExp(',', ['g']), // 逗号
    REGEXP_MONEY: /^(([1-9]\d*)(\.\d{1,2})?)$|^(0\.0?([1-9]\d?))$|^([0]{1})$/, // 金额正则
    _require: /.+/, // 非空正则
    _email: /^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, // 邮箱正则
    _emailOrEmpty: /^\s*$|^\w+([-+.]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*$/, // 邮箱正则, 可不填
    _phone: /(\d{2,5}-\d{7,8}?)/, // 固话正则
    _mobile: /^1[0-9]{10}$/, // 手机号码
    _phone2: /^\s*$|(^1[0-9]{10}$|(\d{2,5}-\d{7,8}?))/, // 备用号
    _url: /^http:\/\/[A-Za-z0-9]+\.[A-Za-z0-9]+[\/=\?%\-&_~`@[\]\':+!]*([^<>\"\"])*$/, // URL地址
    _idCard: /^(\d{18,18}|\d{15,15}|\d{17,17}x)$/, // 账户正则
    _accountNo: /^\d{16,22}$/,
    _accountNoTwo: /^\d{6,32}$/,
    _accountNoThree: /^[0-9][0123456789-]{5,32}$/,
    _manager: /^\s*$|^[A-Za-z\d]{7,12}$/, // 客户经理， 可以为空或7位 /^\s*$|^(\d){7,20}$/
    _manager1: /^[A-Za-z\d]{7,12}$/, // 客户经理， 不为空
    _currency: /^(([1-9]\d*)(\.\d{1,2})?)$|^(0\.0?([1-9]\d?))$/, // 金额
    _number: /^\d+$/, // 纯数字
    _zip: /^[1-9]\d{5}$/, // 邮箱
    _qq: /^[1-9]\d{4,8}$/, // QQ号码
    _integer: /^[-\+]?\d+$/, // 整数
    _double: /^[-\+]?\d+(\.\d+)?$/, // 浮点型
    _english: /^[A-Za-z]+$/, // 纯字母
    _chinese: /^[\u0391-\uFFE5]+$/, // 中文
    _mobildPhone: /^1[3456789]\d{9}$/,
    _agtCertNo: /^[A-Za-z0-9]+$/, // 推介人编号字母、数字,
    _mobilePhone: /^1[3457689]\d{9}$/, // 手机号码--联通、移动、电信
    _idCard15: /^[1-9]\d{5}\d{2}((0[1-9])|(10|11|12))(([0-2][1-9])|10|20|30|31)\d{2}$/, // 15位的证件号码
    _idCard18: /^[1-9][0-9]{5}([1][9][0-9]{2}|[2][0][0-9]{2})([0][1-9]|[1][0|1|2])([0][1-9]|[1|2][0-9]|[3][0|1])[0-9]{3}([0-9]|[X])$/, // 18位的证件号码
    _special_firstcode: /^[(\｝)(\｛)(\（)(\）)(\.)(\,)(\”)(\—)(\？)(\！)(\《)(\》)(\￥)(\…)]+/,
    _special_include: /[(\:)(\")(\$)(\')(\`)(\^)(\[)(\])(\~)(\{)(\})]+/,
    _special_char: /[(\~)(\!)(\@)(\#)(\$)(\%)(\^)(\&)(\*)(\\)(\/)(\<)(\>)(\?)]+/,
    _special_firstcode_two: /\\|\/|\｝|\｛|\?|\？|\《|\》|\￥|\!|\@|\#|\*|\"|\“|\”|\'|\‘|\’|\<|\>|\{|\}|\[|\]|\【|\】|\、|\^|\$|\!|\~|\`|\|/g,
    _special_char_two: /\\|\/|\｝|\｛|\?|\？|\《|\》|\￥|\!|\@|\#|\*|\"|\“|\”|\'|\‘|\’|\<|\>|\{|\}|\[|\]|\【|\】|\、|\^|\$|\!|\~|\`|\|/g,
    _special_type: /[\s""`~!@#$%^&*()_/\-+=<>?:"{}|,.;'\\[\]·~！@#￥%……&*（）——\-+={}|《》？：“”【】、；‘’'，。、]/im, // 特殊字符
    _smsCode: /^\d{6}$/, // 6位验证码（纯数字）
    _pwd: /^\d{6}$/, // 6位交易密码（纯数字）
    _keywords: /^[\u4E00-\u9FA5\uf900-\ufa2d·s]{2,20}$/,
    _postOffice: /^[0-9]{6}$/,
    _namePinyin: /^\s*$|^[A-Za-z]{1,6}\s+[A-Za-z]{1,6}$|^[A-Za-z]{1,6}\s+[A-Za-z]{1,6}\s+[A-Za-z]{1,6}$|^[A-Za-z]{1,6}\s+[A-Za-z]{1,6}\s+[A-Za-z]{1,6}\s+[A-Za-z]{1,6}/,
    _loginPwd: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,12}$/, //登录密码  /^[A-Za-z0-9]{8,16}$/
    _idCardAll:
        /^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/, //身份证 支持一代二代
    _idCardAll1:
        /^[1-9][0-9]{5}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/, //身份证 支持一代二代
    _pinPwd: /^(?=.*[A-Za-z])(?=.*\d)[A-Za-z\d]{6,12}$/, //PIN密码
    _number_4: /^(0|-?[1-9]\d{0,3})$/, //4位整数，不含浮点数
    _number_percent: /^[1-9]{1,2}\.\d{1,3}$|^[1][0-0]{1,2}\.\d{1,3}$|^[1-9]{1,2}$|^[1][0-0]{1,2}$/, //整数最大100，3位浮点数
    _min3: /^.{3,}$/, //输入至少3个字符
    _min2: /^.{2,}$/, //输入至少2个字符
    _min8: /^.{8,}$/, //输入至少8个字符
    _userName:
        /^\d+$|^\d{6}((((((19|20)\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|(((19|20)\d{2})(0[13578]|1[02])31)|((19|20)\d{2})02(0[1-9]|1\d|2[0-8])|((((19|20)([13579][26]|[2468][048]|0[48]))|(2000))0229))\d{3})|((((\d{2})(0[13-9]|1[012])(0[1-9]|[12]\d|30))|((\d{2})(0[13578]|1[02])31)|((\d{2})02(0[1-9]|1\d|2[0-8]))|(([13579][26]|[2468][048]|0[048])0229))\d{2}))(\d|X|x)$/, //登录户名
    _name: /^(?!·)(?!.*?·$)([\u4e00-\u9fa5]|·(?!·))+$/, //姓名正则
    _address: /^[\u4e00-\u9fa5a-zA-Z0-9-]+$/, //汉字数字字母
    _number3: /^[0-9]{3}$/,
    _number4: /^[0-9]{4}$/
}
/**
 * 判断平台类型
 * this.$os.ios/android/wechat/ipad
 * this.$os.version
 */
export function platformName() {
    const platform = {};
    function detect(ua) {
        this.os = {
            wechat: false,
            android: false,
            ios: false,
            iphone: false,
            ipad: false
        };
        var funcs = [
            function () {
                // wechat
                // eslint-disable-next-line no-useless-escape
                var wechat = ua.match(/(MicroMessenger)\/([\d\.]+)/i);
                if (wechat) {
                    // wechat
                    this.os.wechat = {
                        version: wechat[2].replace(/_/g, '.')
                    };
                }
                return false;
            },
            function () {
                // android
                // eslint-disable-next-line no-useless-escape
                var android = ua.match(/(Android);?[\s\/]+([\d.]+)?/);
                if (android) {
                    this.os.android = true;
                    this.os.version = android[2];

                    this.os.isBadAndroid = !/Chrome\/\d/.test(window.navigator.appVersion);
                }
                return this.os.android === true;
            },
            function () {
                // ios
                var iphone = ua.match(/(iPhone\sOS)\s([\d_]+)/);
                if (iphone) {
                    // iphone
                    this.os.ios = this.os.iphone = true;
                    this.os.version = iphone[2].replace(/_/g, '.');
                } else {
                    var ipad = ua.match(/(iPad).*OS\s([\d_]+)/);
                    if (ipad) {
                        // ipad
                        this.os.ios = this.os.ipad = true;
                        this.os.version = ipad[2].replace(/_/g, '.');
                    }
                }
                return this.os.ios === true;
            }
        ];
        [].every.call(funcs, function (func) {
            return !func.call(platform);
        });
    }
    detect.call(platform, navigator.userAgent);
    return platform.os;
}
